package com.javaclimb.drug.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.javaclimb.drug.entity.Discard;


import com.javaclimb.drug.entity.Saleinfo;
import com.javaclimb.drug.mapper.DiscardMapper;
import com.javaclimb.drug.service.IDiscardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 销毁记录service实现类
 */
@Service
public class DiscardServiceImpl extends ServiceImpl<DiscardMapper, Discard> implements IDiscardService {


    @Autowired
    private DiscardMapper discardMapper;


    /**
     * 分页查询销售记录数据
     *
     * @param pageNum  第几页
     * @param pageSize 每页多少条数据
     * @param param    查询参数-销售记录名称
     * @return
     */
    @Override
    public IPage<Discard> selectDiscardPage(int pageNum, int pageSize, String param) {
        QueryWrapper<Discard> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(param)) {
            queryWrapper.like("dname", param);
        }
        Page<Discard> page = new Page<>(pageNum, pageSize);
        return discardMapper.selectPage(page, queryWrapper);
    }


    /**
     * 新增一条销售记录信息
     *
     * @param discard
     */
    @Override
    public int addDiscard(Discard discard) {
        return discardMapper.insert(discard);
    }

    /**
     * 修改一条销售记录信息
     *
     * @param discard
     */
    public int editDiscard(Discard discard) {
        return discardMapper.updateById(discard);
    }

    /**
     * 根据主键id删除一个销毁记录对象
     *
     * @param id
     * @return
     */
    @Override
    public int delDiscardById(Integer id) {
        return discardMapper.deleteById(id);
    }

    @Override
    public Discard querydiscardById(Integer id) {
        return null;
    }

}
